package de.ret_world.eet.code;

/**
 * A single Symbol out of an Alphabet
 * @author Emu
 */
public class Symbol {

    private String symbol;

    /**
     * Creates a new Symbol with the given String
     * @param symbol the String to create the Symbol
     */
    public Symbol(String symbol) {
        this.symbol = symbol;
    }

    /**
     * @param symbol sets the String of the Symbol
     */
    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    /**
     * @return the length of the inside String
     */
    public int getLength() {
        return symbol.length();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Symbol other = (Symbol) obj;
        if ((this.symbol == null) ? (other.symbol != null) : !this.symbol.equals(other.symbol)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 41 * hash + (this.symbol != null ? this.symbol.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return symbol;
    }
}
